import { defineComponent } from 'vue'
import { log } from './utils'

export default defineComponent({
    name: 'Render',
    props: {
        initData: {
            type: Object,
            default: () => ({})
        },
        item: {
            type: Object,
            default: () => ({})
        },
        items: {
            type: Array,
            default: () => []
        },
        form: {
            type: Object,
            default: () => ({})
        }
    },
    setup(props, { emit, expose }) {
        return () => {
            if (!props.item.render) log(`字段${props.item.key}：`, '缺少render方法', 'warn')
            return props.item.render && props.item.render({
                item: props.item,
                items: props.items,
                form: props.form,
                initData: props.initData
            })
        }
    }
})